1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.google.common.collect.testing.google;
18
19 import com.google.common.annotations.GwtCompatible;
20 import com.google.common.collect.BiMap;
21 import com.google.common.collect.testing.Helpers;
22 import com.google.common.collect.testing.SampleElements;
23
24 import java.util.List;
25 import java.util.Map;
26 import java.util.Map.Entry;
27
28
29
30
31
32
33
34
35
36
37 @GwtCompatible
38 public abstract class TestStringBiMapGenerator
39 implements TestBiMapGenerator<String, String> {
40
41 @Override
42 public SampleElements<Map.Entry<String, String>> samples() {
43 return new SampleElements<Map.Entry<String, String>>(
44 Helpers.mapEntry("one", "January"),
45 Helpers.mapEntry("two", "February"),
46 Helpers.mapEntry("three", "March"),
47 Helpers.mapEntry("four", "April"),
48 Helpers.mapEntry("five", "May")
49 );
50 }
51
52 @Override
53 public final BiMap<String, String> create(Object... entries) {
54 @SuppressWarnings("unchecked")
55 Entry<String, String>[] array = new Entry[entries.length];
56 int i = 0;
57 for (Object o : entries) {
58 @SuppressWarnings("unchecked")
59 Entry<String, String> e = (Entry<String, String>) o;
60 array[i++] = e;
61 }
62 return create(array);
63 }
64
65 protected abstract BiMap<String, String> create(
66 Entry<String, String>[] entries);
67
68 @Override
69 @SuppressWarnings("unchecked")
70 public final Entry<String, String>[] createArray(int length) {
71 return new Entry[length];
72 }
73
74 @Override
75 public final String[] createKeyArray(int length) {
76 return new String[length];
77 }
78
79 @Override
80 public final String[] createValueArray(int length) {
81 return new String[length];
82 }
83
84
85 @Override
86 public Iterable<Entry<String, String>> order(
87 List<Entry<String, String>> insertionOrder) {
88 return insertionOrder;
89 }
90 }